package hz.mobileproject.pda.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import hz.mobileproject.pda.R;


/**
 * Created by ku on 2016/9/7.
 */
public class WorkAdapter extends RecyclerView.Adapter<WorkAdapter.MyViewHolder>{

    private Context mContext;

    public WorkAdapter(Context context) {
        mContext = context;
    }

    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.mOnItemClickListener = onItemClickListener;
    }

    public interface OnItemClickListener{
        void onClick(int position);
    }


    @Override
    public WorkAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_work,null);

        WorkAdapter.MyViewHolder viewHolder = new MyViewHolder(view);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(WorkAdapter.MyViewHolder holder, final int position) {

        holder.layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mOnItemClickListener != null){
                    mOnItemClickListener.onClick(position);
                }
            }
        });

        switch (position){
//            case 0:
//                holder.iv.setImageResource(R.mipmap.work_peoplecheck);
//                holder.tv.setText("电子巡警");
//                break;
//
//            case 1:
//                holder.iv.setImageResource(R.mipmap.work_toolcheck);
//                holder.tv.setText("工具管理");
//                break;
//
//            case 2:
//                holder.iv.setImageResource(R.mipmap.work_callmanage);
//                holder.tv.setText("现场处置");
//                break;
//
//            case 3:
//                holder.iv.setImageResource(R.mipmap.work_checkequipment);
//                holder.tv.setText("消防器材检查");
//                break;
//
//            case 4:
//                holder.iv.setImageResource(R.mipmap.work_placecheck);
//                holder.tv.setText("重点部位巡查");
//                break;
//
//            case 5:
//                holder.iv.setImageResource(R.mipmap.work_ask);
//                holder.tv.setText("零星报备");
//                break;
//
//            case 6:
//                holder.iv.setImageResource(R.mipmap.icon_jiaoyutanhua);
//                holder.tv.setText("教育谈话");
//                break;
//
//            case 7:
//                holder.iv.setImageResource(R.mipmap.warning);
//                holder.tv.setText("应急处置");
//                break;
//
//            case 8:
//                holder.iv.setImageResource(R.mipmap.phone);
//                holder.tv.setText("亲情电话");
//                break;
//
//            case 9:
//                holder.iv.setImageResource(R.mipmap.voice);
//                holder.tv.setText("会见录音");
//                break;
//            case 10:
//                holder.iv.setImageResource(R.mipmap.zichanpandian);
//                holder.tv.setText("资产盘点");
//                break;
//            case 11:
//                holder.iv.setImageResource(R.mipmap.icon_kaoqinguanli);
//                holder.tv.setText("考勤管理");
//                break;


                //TODO 广西江宁监狱  只部署电子点名和教育谈话
            case 0:
                holder.iv.setImageResource(R.mipmap.work_peoplecheck);
                holder.tv.setText("电子巡警");
                break;
            case 1:
                holder.iv.setImageResource(R.mipmap.icon_jiaoyutanhua);
                holder.tv.setText("教育谈话");
                break;
        }

    }

    @Override
    public int getItemCount() {
        return 2;
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

        RelativeLayout layout;
        ImageView iv;
        TextView tv;

        public MyViewHolder(View itemView) {
            super(itemView);


            iv = (ImageView) itemView.findViewById(R.id.iv);
            tv = (TextView) itemView.findViewById(R.id.tv);
            layout = (RelativeLayout) itemView.findViewById(R.id.layout);
        }
    }
}
